package cn.chainfind.common.enums;

/**
 * ================================
 *
 * @author: ZCB
 * @email: zhang-cb@foxmail.com
 * @time: 2020/11/23 23:21
 * @version: 1.0
 * @description: =================================
 */
public enum UserConstant {

    AUTH_INVALID_ACCOUNT(700, "账号密码不对"),
    AUTH_CAPTCHA_UNSUPPORT(701, "小程序后台验证码服务不支持"),

    AUTH_CAPTCHA_VALID(699, "验证码不正确"),
    AUTH_CAPTCHA_FREQUENCY(702,"验证码未超时1分钟，不能发送"),
    AUTH_CAPTCHA_UNMATCH(703, "验证码错误"),
    AUTH_NAME_REGISTERED(704,"用户名已注册"),
    AUTH_MOBILE_REGISTERED(705, "手机号已注册"),
    AUTH_MOBILE_UNREGISTERED(706,"手机号未注册"),
    AUTH_INVALID_MOBILE(707, "手机号格式不正确"),


    INVALID_USER(852, "无效用户");

    private final Integer code;
    private final String desc;

    UserConstant(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static UserConstant getInstance(Integer code) {
        if (code != null) {
            for (UserConstant tmp : UserConstant.values()) {
                if (tmp.code.intValue() == code.intValue()) {
                    return tmp;
                }
            }
        }
        return null;
    }

    public Integer code() {
        return code;
    }

    public String desc() {
        return desc;
    }
}
